package edu.mit.media.fv.aqwidgets
{
	import edu.mit.media.fv.components.*;
	import edu.mit.media.fv.events.*;
	import edu.mit.media.fv.fluidspace.*;
	
	import flash.display.*;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.utils.Timer;

	public class AQTimeCell extends MovieClip
	{
		//private var text:TextField;
		private var start:Date;
		private var end:Date;
		private var gran:int;
		public function AQTimeCell()
		{
			super();
			text.selectable = false;
		}
		public function setDate(date:Date, gran:int, deltaTime:int):void{
			if(gran == 0){//year
				this.start = new Date(date.fullYearUTC+deltaTime,0);
				this.end = new Date(date.fullYearUTC+deltaTime+1,0);
				this.gran = gran;
				this.text.text = TimeUtil.toYearString(start.fullYearUTC);
			}else if(gran == 1){//month
				this.start = new Date(date.fullYearUTC, date.monthUTC+deltaTime);
				this.end = new Date(date.fullYearUTC, date.monthUTC+deltaTime+1);
				this.gran = gran;
				this.text.text = TimeUtil.toMonthString(start.monthUTC);
			}else if(gran == 2){//day
				this.start = new Date(date.fullYearUTC, date.monthUTC, date.dateUTC+deltaTime);
				this.end = new Date(date.fullYearUTC, date.monthUTC, date.dateUTC+deltaTime+1);
				this.gran = gran;
				this.text.text = TimeUtil.toDayString(start.dayUTC)+" "+start.dateUTC;
			}else if(gran == 3){//hour
				this.start = new Date(date.fullYearUTC, date.monthUTC, date.dateUTC, date.hours+deltaTime);
				this.end = new Date(date.fullYearUTC, date.monthUTC, date.dateUTC, date.hours+deltaTime+1);
				this.gran = gran;
				this.text.text = TimeUtil.toHourString(start.hours);
			}else if(gran == 4){//minute
				this.start = new Date(date.fullYearUTC, date.monthUTC, date.dateUTC, date.hours, date.minutesUTC+deltaTime);
				this.end = new Date(date.fullYearUTC, date.monthUTC, date.dateUTC, date.hours, date.minutesUTC+deltaTime+1);
				this.gran = gran;
				this.text.text = TimeUtil.toMinuteString(start.hours, start.minutesUTC);
			}
			//trace(deltaTime+", "+date.hoursUTC+", "+date+"; start: "+start+"; end: "+end);
		}
		public function get startDate():Date{
			return this.start;
		}
		public function get endDate():Date{
			return this.end;
		}
		
	}
}